<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/plugins/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="/css/global.css" media="all">
    <link rel="stylesheet" href="/plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="/css/table.css"/>
    <title>已关联交易对(web)</title>
    <style type="text/css">
        .searcheBottom{margin-bottom: 10px;}
        body{overflow-y: scroll;}
    </style>
</head>
<body class="admin-main">
<blockquote class="layui-elem-quote">
    <div class="demoTable">
        <div class="layui-inline searcheBottom">
            <div class="layui-inline" style="margin-right: 30px;">
                <h3><b>当前货币名称：${coinNameCn!}</b></h3>
                <input id="id" class="layui-input" autocomplete="off" value="${currencyId!}" style="display: none;"/>
                <input id="symbol" class="layui-input" autocomplete="off" value="${symbol!}" style="display: none;"/>
            </div>
        </div>
        <div class="layui-inline searcheBottom">
            <a data-opt="add" href="/manage/currency/webExTra?id=${currencyId!}&coinNameCn=${coinNameCn!}&symbol=${symbol!}&size=${size!}" class="layui-btn" id="addReport"><i class="layui-icon">&#xe608;</i>关联交易对</a>
            <a class="layui-btn layui-btn-primary" href="/manage/currency/currencymanage">返回</a>
        </div>
    </div>
</blockquote>
<span style="font-size: 16px;"><b>已关联交易对(web)</b></span>
<table class="layui-hide" id="currencyTra" lay-filter="tableFilter"></table>
</div>
<script type="text/javascript" src="/plugins/layui/layui.js"></script>
<script>
    layui.use(['jquery','table','laydate','layer','form','util'],function(){
        var $=layui.jquery,table=layui.table,laydate = layui.laydate,
            layer = layui.layer,form = layui.form,util=layui.util;

        pageInit();
        //表格渲染
        function pageInit(){
            table.render({
                elem:"#currencyTra",
                url:"/manage/currency/listCurrencyTra",
                method:"post",
                where:{currencyId: parseInt(${currencyId!})},
                cols:[[
                    {field:'id', title: 'ID', sort: true,align:'center'},
                    {field:'exchangeName', title: '交易所',align:'center'},
                    {field:'transactionAlias', title: '交易对',align:'center'},
                    {field:'quantifyCurrencySelect', title: '量化选币',align:'center',
                        templet: function(d){
                            if(d.quantifyCurrencySelect== true){
                                return '<div class="layui-btn layui-btn-green layui-btn-xs">支持</div>'
                            } else{
                                return '<div class="layui-btn layui-bg-gray layui-btn-xs">不支持</div>';
                            }
                        }
                    },
                    {field: 'tool', title:"操作",align:'left',align:'center',
                        templet:function(d){
                            var tool ='';
                            if(d.quantifyCurrencySelect == true){
                                tool+= '<div class="layui-btn layui-btn-warm layui-btn-xs" lay-event="qcs">取消量化选币</div>'
                            }else{
                                tool+= '<div class="layui-btn layui-bg-green layui-btn-xs" lay-event="qcs">设置量化选币</div>';
                            }
                            return tool+= '<a href="#" class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>';
                        }
                    }
                ]]
            });
        };
        var id = "${currencyId!}";
        table.on('tool(tableFilter)', function(obj){
            var data = obj.data;
            if (obj.event == "del") {
                $.ajax({
                    url:"/manage/currency/delCurrencyTra",
                    type:"post",
                    dataType:"json",
                    data:{"id":id},
                    success:function(count){
                        pageInit();
                    }
                });
            }else if(obj.event == "qcs"){
                $.ajax({
                    url:"/manage/extrading/qcsTra",
                    type:"post",
                    dataType:"json",
                    data:{"id":data.id,"quantifyCurrencySelect":data.quantifyCurrencySelect},
                    success:function(count){
                        pageInit();
                    }
                });
            }
        });
    });
</script>

</body>
</html>